package Ventanas;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.BoxLayout;
import javax.swing.JButton;

import fiuba.algo3.tp2.Hectarea;
import fiuba.algo3.tp2.Jugador;
import fiuba.algo3.tp2.Mapa;

import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class VentanaDeJuego extends JFrame {

	JButton[][] grid = new JButton[12][12];
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					VentanaDeJuego frame = new VentanaDeJuego(null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * @param jugador 
	 */
	public VentanaDeJuego(Jugador jugador) {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//setBounds(100, 100, 427, 277);
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
		getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(142, 11, 856, 664);
		getContentPane().add(panel);
		panel.setLayout(new GridLayout(12, 12, 0, 0));
		
		//grid = new JButton[12][12];
		for(int x=0;x<12;x++){
			for(int y=0;y<12;y++){
				grid[x][y] = new JButton("("+x+","+y+")");
				panel.add(grid[x][y]);
			}
		}
		//panel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//panel.pack();
		panel.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent e) {
		  for (int i = 0; i < 12; i++) {
		    for (int j = 0; j < 12; j++) {
		       if (grid[i][j] == e.getSource())
		       {
		    	   String enteroString1 = Integer.toString(i);
		    	   System.out.println(enteroString1);
		    	   String enteroString2 = Integer.toString(j);
		    	   System.out.println(enteroString2);
		    	   Mapa mapa = Mapa.getInstance();
		    	   Hectarea hectareaActual = mapa.coordenada(i, j);
		       }
		    }
		  }
		}
}
		




		/*JButton button = new JButton();
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		panel.add(button);
		
		JButton button_1 = new JButton();
		panel.add(button_1);
		
		JButton button_2 = new JButton();
		panel.add(button_2);
		
		JButton button_3 = new JButton();
		panel.add(button_3);
		
		JButton button_4 = new JButton();
		panel.add(button_4);
		
		JButton button_5 = new JButton();
		panel.add(button_5);
		
		JButton button_6 = new JButton();
		panel.add(button_6);
		
		JButton button_11 = new JButton();
		panel.add(button_11);
		
		JButton button_12 = new JButton();
		panel.add(button_12);
		
		JButton button_13 = new JButton();
		panel.add(button_13);
		
		JButton button_14 = new JButton();
		panel.add(button_14);
		
		JButton button_15 = new JButton();
		panel.add(button_15);
		
		JButton button_16 = new JButton();
		panel.add(button_16);
		
		JButton button_23 = new JButton();
		panel.add(button_23);
		
		JButton button_24 = new JButton();
		panel.add(button_24);
		
		JButton button_25 = new JButton();
		panel.add(button_25);
		
		JButton button_26 = new JButton();
		panel.add(button_26);
		
		JButton button_27 = new JButton();
		panel.add(button_27);
		
		JButton button_28 = new JButton();
		panel.add(button_28);
		
		JButton button_35 = new JButton();
		panel.add(button_35);
		
		JButton button_36 = new JButton();
		panel.add(button_36);
		
		JButton button_37 = new JButton();
		panel.add(button_37);
		
		JButton button_47 = new JButton();
		panel.add(button_47);
		
		JButton button_48 = new JButton();
		panel.add(button_48);
		
		JButton button_49 = new JButton();
		panel.add(button_49);
		
		JButton button_50 = new JButton();
		panel.add(button_50);
		
		JButton button_51 = new JButton();
		panel.add(button_51);
		
		JButton button_52 = new JButton();
		panel.add(button_52);
		
		JButton button_59 = new JButton("New button");
		panel.add(button_59);
		
		JButton button_60 = new JButton("New button");
		panel.add(button_60);
		
		JButton button_61 = new JButton("New button");
		panel.add(button_61);
		
		JButton button_62 = new JButton("New button");
		panel.add(button_62);
		
		JButton button_63 = new JButton("New button");
		panel.add(button_63);
		
		JButton button_64 = new JButton("New button");
		panel.add(button_64);
		
		JButton button_71 = new JButton("New button");
		panel.add(button_71);
		
		JButton button_72 = new JButton("New button");
		panel.add(button_72);
		
		JButton button_73 = new JButton("New button");
		panel.add(button_73);
		
		JButton button_74 = new JButton("New button");
		panel.add(button_74);
		
		JButton button_75 = new JButton("New button");
		panel.add(button_75);
		
		JButton button_76 = new JButton("New button");
		panel.add(button_76);
		
		JButton button_77 = new JButton("New button");
		panel.add(button_77);
		
		JButton button_107 = new JButton("New button");
		panel.add(button_107);
		
		JButton button_108 = new JButton("New button");
		panel.add(button_108);
		
		JButton button_109 = new JButton("New button");
		panel.add(button_109);
		
		JButton button_110 = new JButton("New button");
		panel.add(button_110);
		
		JButton button_111 = new JButton("New button");
		panel.add(button_111);
		
		JButton button_112 = new JButton("New button");
		panel.add(button_112);
		
		JButton button_119 = new JButton("New button");
		panel.add(button_119);
		
		JButton button_120 = new JButton("New button");
		panel.add(button_120);
		
		JButton button_121 = new JButton("New button");
		panel.add(button_121);
		
		JButton button_122 = new JButton("New button");
		panel.add(button_122);
		
		JButton button_123 = new JButton("New button");
		panel.add(button_123);
		
		JButton button_124 = new JButton("New button");
		panel.add(button_124);
		
		JButton button_125 = new JButton("New button");
		panel.add(button_125);
		
		JButton button_126 = new JButton("New button");
		panel.add(button_126);
		
		JButton button_127 = new JButton("New button");
		panel.add(button_127);
		
		JButton button_128 = new JButton("New button");
		panel.add(button_128);
		
		JButton button_129 = new JButton("New button");
		panel.add(button_129);
		
		JButton button_130 = new JButton("New button");
		panel.add(button_130);
		
		JButton button_113 = new JButton("New button");
		panel.add(button_113);
		
		JButton button_114 = new JButton("New button");
		panel.add(button_114);
		
		JButton button_115 = new JButton("New button");
		panel.add(button_115);
		
		JButton button_116 = new JButton("New button");
		panel.add(button_116);
		
		JButton button_131 = new JButton("New button");
		panel.add(button_131);
		
		JButton button_132 = new JButton("New button");
		panel.add(button_132);
		
		JButton button_133 = new JButton("New button");
		panel.add(button_133);
		
		JButton button_134 = new JButton("New button");
		panel.add(button_134);
		
		JButton button_135 = new JButton("New button");
		panel.add(button_135);
		
		JButton button_136 = new JButton("New button");
		panel.add(button_136);
		
		JButton button_137 = new JButton("New button");
		panel.add(button_137);
		
		JButton button_138 = new JButton("New button");
		panel.add(button_138);
		
		JButton button_139 = new JButton("New button");
		panel.add(button_139);
		
		JButton button_140 = new JButton("New button");
		panel.add(button_140);
		
		JButton button_141 = new JButton("New button");
		panel.add(button_141);
		
		JButton button_142 = new JButton("New button");
		panel.add(button_142);
		
		JButton button_117 = new JButton("New button");
		panel.add(button_117);
		
		JButton button_118 = new JButton("New button");
		panel.add(button_118);
		
		JButton button_78 = new JButton("New button");
		panel.add(button_78);
		
		JButton button_79 = new JButton("New button");
		panel.add(button_79);
		
		JButton button_80 = new JButton("New button");
		panel.add(button_80);
		
		JButton button_81 = new JButton("New button");
		panel.add(button_81);
		
		JButton button_82 = new JButton("New button");
		panel.add(button_82);
		
		JButton button_65 = new JButton("New button");
		panel.add(button_65);
		
		JButton button_83 = new JButton("New button");
		panel.add(button_83);
		
		JButton button_84 = new JButton("New button");
		panel.add(button_84);
		
		JButton button_85 = new JButton("New button");
		panel.add(button_85);
		
		JButton button_86 = new JButton("New button");
		panel.add(button_86);
		
		JButton button_87 = new JButton("New button");
		panel.add(button_87);
		
		JButton button_88 = new JButton("New button");
		panel.add(button_88);
		
		JButton button_89 = new JButton("New button");
		panel.add(button_89);
		
		JButton button_90 = new JButton("New button");
		panel.add(button_90);
		
		JButton button_91 = new JButton("New button");
		panel.add(button_91);
		
		JButton button_92 = new JButton("New button");
		panel.add(button_92);
		
		JButton button_93 = new JButton("New button");
		panel.add(button_93);
		
		JButton button_94 = new JButton("New button");
		panel.add(button_94);
		
		JButton button_66 = new JButton("New button");
		panel.add(button_66);
		
		JButton button_67 = new JButton("New button");
		panel.add(button_67);
		
		JButton button_95 = new JButton("New button");
		panel.add(button_95);
		
		JButton button_96 = new JButton("New button");
		panel.add(button_96);
		
		JButton button_97 = new JButton("New button");
		panel.add(button_97);
		
		JButton button_98 = new JButton("New button");
		panel.add(button_98);
		
		JButton button_99 = new JButton("New button");
		panel.add(button_99);
		
		JButton button_100 = new JButton("New button");
		panel.add(button_100);
		
		JButton button_101 = new JButton("New button");
		panel.add(button_101);
		
		JButton button_102 = new JButton("New button");
		panel.add(button_102);
		
		JButton button_103 = new JButton("New button");
		panel.add(button_103);
		
		JButton button_104 = new JButton("New button");
		panel.add(button_104);
		
		JButton button_105 = new JButton("New button");
		panel.add(button_105);
		
		JButton button_106 = new JButton("New button");
		panel.add(button_106);
		
		JButton button_68 = new JButton("New button");
		panel.add(button_68);
		
		JButton button_69 = new JButton("New button");
		panel.add(button_69);
		
		JButton button_70 = new JButton("New button");
		panel.add(button_70);
		
		JButton button_53 = new JButton("New button");
		panel.add(button_53);
		
		JButton button_54 = new JButton("New button");
		panel.add(button_54);
		
		JButton button_55 = new JButton("New button");
		panel.add(button_55);
		
		JButton button_56 = new JButton("New button");
		panel.add(button_56);
		
		JButton button_57 = new JButton("New button");
		panel.add(button_57);
		
		JButton button_58 = new JButton("New button");
		panel.add(button_58);
		
		JButton button_38 = new JButton("New button");
		panel.add(button_38);
		
		JButton button_39 = new JButton("New button");
		panel.add(button_39);
		
		JButton button_40 = new JButton("New button");
		panel.add(button_40);
		
		JButton button_41 = new JButton("New button");
		panel.add(button_41);
		
		JButton button_42 = new JButton("New button");
		panel.add(button_42);
		
		JButton button_43 = new JButton("New button");
		panel.add(button_43);
		
		JButton button_44 = new JButton("New button");
		panel.add(button_44);
		
		JButton button_45 = new JButton("New button");
		panel.add(button_45);
		
		JButton button_46 = new JButton("New button");
		panel.add(button_46);
		
		JButton button_29 = new JButton("New button");
		panel.add(button_29);
		
		JButton button_30 = new JButton("New button");
		panel.add(button_30);
		
		JButton button_31 = new JButton("New button");
		panel.add(button_31);
		
		JButton button_32 = new JButton("New button");
		panel.add(button_32);
		
		JButton button_33 = new JButton("New button");
		panel.add(button_33);
		
		JButton button_34 = new JButton("New button");
		panel.add(button_34);
		
		JButton button_17 = new JButton("New button");
		panel.add(button_17);
		
		JButton button_18 = new JButton("New button");
		panel.add(button_18);
		
		JButton button_19 = new JButton("New button");
		panel.add(button_19);
		
		JButton button_20 = new JButton("New button");
		panel.add(button_20);
		
		JButton button_21 = new JButton("New button");
		panel.add(button_21);
		
		JButton button_22 = new JButton("New button");
		panel.add(button_22);
		
		JButton button_7 = new JButton("New button");
		panel.add(button_7);
		
		JButton button_8 = new JButton("New button");
		panel.add(button_8);
		
		JButton button_9 = new JButton("New button");
		panel.add(button_9);
		
		JButton button_10 = new JButton("New button");
		panel.add(button_10);
		
		JButton btnNewButton = new JButton("New button");
		panel.add(btnNewButton);

	}*/
